/**
 * 
 */
package PyroBots.Modele;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Observable;
import java.util.Set;

public class Flotte extends Observable implements Serializable{

	private HashSet<Robot> robot;
	private String nom;
	
	
	
	public Flotte() {
		this.robot = new HashSet<Robot>();
	}

	public HashSet<Robot> getRobot() {
		return robot;
	}

	public String getNom() {
		return nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}

	public HashSet<RobotSerialisablePourFlotte> getFlotteSerialisable() {
		HashSet<RobotSerialisablePourFlotte> tab = new HashSet<RobotSerialisablePourFlotte>();
		for (Robot r : robot){
			tab.add(new RobotSerialisablePourFlotte(r));
		}
		return tab;
	}

	public void setFlotteSerialisable(Set<RobotSerialisablePourFlotte> tab) {
		robot.clear();
		for (RobotSerialisablePourFlotte r : tab){
			this.addRobot(new Robot(r));
		}
	}
	
	public void addRobot(Robot r){
		this.robot.add(r);
		this.setChanged();
		this.notifyObservers();
	}
	
	public void removeRobot (Robot r) {
		this.robot.remove(r);
		this.setChanged();
		this.notifyObservers();
	}

}